package com.heima.model.behavior.pojos;

import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.Getter;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.util.Date;

@Document(value = "ap_behavior_entry")
@Data
public class ApBehaviorEntry implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 行为实体 id 主键
     */
    private String id;

    /**
     * 行为实体的类型 0 - 设备
     *              1 - 用户
     */
    @Field(value = "type")
    private Short type;

    /**
     * 行为实体关联用户 id type[0] - 设备 id
     *                  type[1] - 用户 id
     */
    @Field(value = "ref_id")
    private Integer refId;

    /**
     * 行为实体的创建时间
     */
    @Field(value = "created_time")
    private Date createdTime;

    public enum Type{
        USER((short)1),EQUIPMENT((short)0);
        @Getter
        private Short code;
        private Type(Short code){
            this.code = code;
        }
    }

    public Boolean isUser(){
        if(this.getType() != null && this.getType().equals(Type.USER.getCode())){
            return true;
        }
        return false;
    }
}
